package edu.gdkm.demo6.demo3;



public class Tv implements RemoteController {
    private boolean power;//开关
    private int volumn;
    private int volumnTemp;

    public Tv() {
        this.power = false;
        this.volumn = DEFAULT_VOLUMN;
    }

    public Tv(boolean power, int volumn) {
        this.power = power;
        this.volumn = volumn;
    }

    @Override
    public void powerOnOff() {
        //如果开机则关机，如果关机则开机，！代表取反
        this.power=!this.power;

        if(this.power){
            //开机时，音量恢复暂存状态
            volumn=volumnTemp;
        }else{
            //关机时，将音量存入暂存变量中，音量归零
            volumnTemp=volumn;
            volumn=0;

        }
    }

    @Override
    public void volumnUp(int increment) {
        volumn = volumn +increment;
    }

    @Override
    public void volumnDown(int increment) {
        volumn = volumn - increment;
    }

    @Override
    public void outPut() {
        System.out.print("电视状态："+power);
        System.out.println(",当前音量是："+volumn);
    }
}
